<template>
  <view class="total">
    <view class="stars">
      <view class="stars-normal">
        <view class="box">
          <block v-for="i in 5" :key="i"><text class="iconfont">&#xe870;</text></block>
        </view>
      </view>
      <view class="stars-selected" :style="{ width: (rate / 5) * 100 + '%' }">
        <view class="box">
          <block v-for="j in 5" :key="j"><text class="iconfont">&#xe870;</text></block>
        </view>
      </view>
    </view>
    <text>{{ rate }}{{ (rate * 10) % 10 == 0 ? '.0' : '' }}分</text>
  </view>
</template>

<script>
  export default {
    props: {
      rate: {
        type: Number,
        default: 4.6
      }
    },
    data() {
      return {

      };
    }
  }
</script>

<style lang="scss">
  @import './iconfont.css';

  .total {
    /* flex: 1; */
    height: 100%;
    font-size: 30upx;
    color: #d76d9d;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .stars {
    width: 180upx;
    height: 36upx;
    position: relative;
  }

  .stars .box {
    width: 180upx;
  }

  .stars-normal {
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    color: #ccc;
  }

  .stars-selected {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    color: #fde16d;
    overflow: hidden;
  }

  .stars-selected .iconfont,
  .stars-normal .iconfont {
    font-size: 36upx;
  }
</style>
